//
//  Array+JXE.swift12
//  JXUtilsDemo
//
//  Created by Zhu Jinxin on 2018/11/27.
//  Copyright © 2018 Zhu Jinxin. All rights reserved.
//

import Foundation
import UIKit

extension Array where Element: Equatable {
    
    //remove the objet of specified index
    mutating func remove(object: Element) {
        if let index = index(of: object) {
            remove(at: index)
        }
    }
    
    func filterDuplicates<E: Equatable>(_ filter: (Element) -> E) -> [Element] {
        var result = [Element]()
        for value in self {
            let key = filter(value)
            if !result.map({filter($0)}).contains(key) {
                result.append(value)
            }
        }
        return result
    }
    
}

//extension Array: NamespaceWrappable {}
//extension JX_TypeWrapper where T : Sequence , T.Iterator.Element == T.Element {
//
////    mutating func remove(object: T) {
////
////        if let index = SELF.index(of:object) {
////
////            remove(at: index)
////        }
////    }
//////
//
//
//}
